package com.edu.fd2130sprbootdemo.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import static org.reflections.util.ConfigurationBuilder.build;

/**
 * @program: fd2130sprbootdemo
 * @description:
 * @author: Teacher.zhang
 * @create: 2022-03-14 10:58
 **/
@Configuration
//要在配置类添加@EnableSwagger2才能启动Swagger
@EnableSwagger2
public class SwaggerConfig {

    public Docket getDocket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .useDefaultResponseMessages(false)
                .select()
                //过滤该路径下的请求生成RESTful api
                /*.paths(Predicates.or(PathSelectors.regex("/api2/.*")))*/
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("学生管理系统 Platform API")//大标题
                .description("学生管理平台 Platform‘s REST API")
                .version("1.0")//版本
                .contact(new Contact("java","http://www.netke.top","fd2135@qq.com"))//作者
                .license("The Apache License Version 2.0")//许可证信息
                .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")//许可证地址
                .build();
    }
}
